package com.example.controller;

import com.example.pojo.Result;
import com.example.service.StatisticsService;
import com.example.dto.SoldCountDTO;
import com.example.vo.GraphVO;
import com.example.vo.SoldCountVO;
import com.example.vo.TicketRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Api(tags = "统计售票模块")
@Slf4j
@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @ApiOperation("查询销售记录")
    @GetMapping
    public Result list(@ApiParam("查询哪个赛事的销售记录") @RequestParam Integer eventID) {
        SoldCountVO soldCountVO = statisticsService.getByEventID(eventID);
        return Result.success(soldCountVO);
    }
    @ApiOperation("查询最近7天的销售记录，绘制成折线图")
    @GetMapping("/graph")
    public Result weekList(@ApiParam("查询哪个赛事的近7天记录") @RequestParam Integer eventID) {
        GraphVO graphVO = statisticsService.weekList(eventID);
        return Result.success(graphVO);
    }
}
